//
//  customerViewController.m
//  HJB
//
//  Created by jiezsoft.com on 14-10-10.
//  Copyright (c) 2014年 jiezsoft.com. All rights reserved.
//

#import "NoticeDetailViewController.h"

#import "HAODEsingleton.h"
#import "UIViewExt.h"

#import "HttpRequest.h"
#import "JSONKit.h"
#import "UIButton+WebCache.h"
#import "UIImageView+WebCache.h"



@interface NoticeDetailViewController ()<MBProgressHUDDelegate,UIGestureRecognizerDelegate,UINavigationControllerDelegate,UITextFieldDelegate,UIScrollViewDelegate,UIWebViewDelegate>

@end

@implementation NoticeDetailViewController

{
   
    HAODEsingleton* commdity;

    NSMutableArray*InfCode1;
    NSMutableArray*Title1;
    NSMutableArray*IssueDate1;
    NSMutableArray*Author1;
    NSMutableArray*Source1;
    NSMutableArray*InfType1;
    UIWebView*webview;
    UIScrollView*MYmainScroll;
    
}
@synthesize alt = alt;
-(void)BackAction:(UIButton *)sender{
    
    
     [self.navigationController popViewControllerAnimated:YES];
}
- (void)viewDidDisappear:(BOOL)animated

{
    
    [super viewDidDisappear:animated];
    
    
    
    self.navigationController.delegate = nil;
    
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    
    
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    
        self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
    UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 43,ScreenWidth, 1)];
    [lineLabel setBackgroundColor:[UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]];
    [self.navigationController.navigationBar addSubview:lineLabel];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    [[UINavigationBar appearance] setBarTintColor:Color];
    
       UIImage* backImage = [UIImage imageNamed:@"fanhui"];
    CGRect backframe = CGRectMake(0,0,30,30);
    UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:backImage forState:UIControlStateNormal];
    backButton.titleLabel.font=[UIFont systemFontOfSize:13];
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    self.navigationController.delegate = self;
    
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    
    
    [self add];
    
    }
-(void)add{
    
  
    
    self.title=@"通告明细";
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     [UIColor blackColor],
                                                                     UITextAttributeTextColor,
                                                                     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1],
                                                                     UITextAttributeTextShadowColor,
                                                                     [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                                                     UITextAttributeTextShadowOffset,
                                                                     [UIFont fontWithName:@"Helvetica Neue" size:tetlefot],
                                                                     UITextAttributeFont,nil]];
    
    
    commdity=[HAODEsingleton shared];
    InfCode1 = [[NSMutableArray alloc] init];
    Title1 = [[NSMutableArray alloc] init];
    IssueDate1 = [[NSMutableArray alloc] init];
    Author1 = [[NSMutableArray alloc] init];
    Source1 = [[NSMutableArray alloc] init];
    
    MYmainScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0,64, ScreenWidth, ScreenHeight)];
 
    MYmainScroll.delegate = self;
    MYmainScroll.userInteractionEnabled = YES;
    MYmainScroll.scrollEnabled = YES;
    MYmainScroll.showsVerticalScrollIndicator = FALSE;
    MYmainScroll.showsHorizontalScrollIndicator = FALSE;
    [self.view addSubview:MYmainScroll];

    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    if (Token ==nil) {
        Token=@"dd";
    }
    
    NSMutableDictionary *params = [NSMutableDictionary new];
    [params setValue:Token forKey:@"tokenId"];
    [params setValue:commdity.orderId forKey:@"noticeId"];
//    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:20 view:self.view];
    
    [HttpRequest requestData:@"/Estate/Notice/DetailPage" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            NSLog(@"====%@",severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];

                webview  = [[UIWebView   alloc]  initWithFrame:CGRectMake( 0,  64,  ScreenWidth ,  ScreenHeight)];
                webview.scalesPageToFit = TRUE;
                [webview   setUserInteractionEnabled: YES ];	 //是否支持交互
                [webview   setDelegate: self ];				 //委托
                [webview   setOpaque: YES ];					 //透明
                [self.view  addSubview : webview];
                NSString * path =[NSString stringWithFormat:@"%@",[severDataDict.dataDict objectForKey:@"noticePage"]];
                ;
                [webview loadRequest:[NSURLRequest requestWithURL:[[NSURL alloc] initWithString :path]]];
                

      
            
            
            
            
            }
            
            
            else{
                [Global hideProgressHUDInternal:self.view];
                
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                    
                    
                }
                
            }
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            
            [Global showTextHudSub:@"连接失败" view:self.view];
            
            
            
        }
        
    }];
    
    
}


#pragma mark - _AutoScrollView view delegate




- (void)showAlertWait
{
    alt = [[UIAlertView alloc] initWithTitle:@"网络不稳定哦 ！" message:@"请确认网络" delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
    
}

- (void)showAlertMessage:(NSString *)msg
{
    alt = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:msg delegate:nil cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
}
- (void)hideAlert
{
    if (alt != nil)
    {
        [alt dismissWithClickedButtonIndex:0 animated:YES];
        alt = nil;
    }
}

@end
